<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});

Route::any('/index', 'IndexController@index')->name('index');
Route::any('/serve', 'WeChatController@serve')->name('serve');


Route::group([ 'prefix' => 'miniapp'], function () {
    Route::get('onLogin', 'WeChatController@onLogin')->name("onLogin");
    Route::get('getUserPhone', 'WeChatController@getUserPhone')->name("getUserPhone");
});

Route::group(['middleware' => ['access_log'],'prefix'=>'auth'], function () {
    Route::post('login', 'AuthController@login')->name('auth.login');

});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'auth'],function(){
    Route::post('logout', 'AuthController@logout')->name("auth.logout");
    Route::get('refresh', 'AuthController@refresh')->name("auth.refresh");
    Route::get('me', 'AuthController@me')->name("auth.me");
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'auth'],function(){
    Route :: resource ( 'permission' , 'PermissionsController' )->except(['edit','create']);
    Route::get('permissionSelect', 'PermissionsController@permissionSelect')->name("auth.permissionSelect");
    //用户额外权限新增
    Route::put('/bind/permissionUser/{user}',"PermissionsController@bindUser")->name("user.permission");
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'accessLog'],function(){
    Route :: resource ( 'accessLog' , 'AccessLogController' )->except(['edit','store','destroy','update','create']);
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'usersManage'],function(){
    Route :: resource ( 'user' , 'UsersController' );
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'rolesManage'],function(){
    Route :: resource ( 'role' , 'RolesController' );
});
Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'goodsCatManage'],function(){
    Route :: resource ( 'goodsCat' , 'GoodsCatController' )->except(['show','edit','create',]);
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'goodsManage'],function(){
    Route :: resource ( 'goods' , 'GoodsController' )->except(['show','edit','create',]);
    Route::post('goodsImage',"GoodsController@goodsImage")->name("goods.image");
    Route::put('/goodsStock/{goods}',"GoodsController@goodsStock")->name("goods.stock");
    Route::put('/goodsStockOperation/{goods}',"GoodsController@goodsStockOperation")->name("goods.stockOperation");
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'stockManage'],function(){
    Route::get('stockList',"GoodsStockController@index")->name("stock.list");
});

Route::group(['middleware' => ['jwt.custom.auth','access_log'],'prefix'=>'roomCheck'],function(){
    Route::get('roomCheckList',"RoomsCheckController@index")->name("roomCheck.list");
    Route::post('roomCheck',"RoomsCheckController@store")->name("roomCheck.store");
    Route::put('/roomCheck/{roomCheck}',"RoomsCheckController@index")->name("roomCheck.update");
    Route::delete('/roomCheck/{roomCheck}',"RoomsCheckController@index")->name("roomCheck.delete");
});
Route::group(['middleware' =>['jwt.custom.auth','access_log'],'prefix'=>'rooms'],function(){
    Route::get('roomsList',"RoomsController@index")->name("rooms.list");
    Route::post('room',"RoomsController@store")->name("rooms.store");
    Route::put('/room/{room}',"RoomsController@update")->name("rooms.update");
    Route::get('/room/{room}',"RoomsController@show")->name("rooms.show");
    Route::delete('/room/{room}',"RoomsController@destroy")->name("rooms.delete");
});

Route::group(['prefix'=>'review'],function(){
    Route::get('list',"ReviewController@list")->name("review.list");
});
